const { resolve } = require('path')
const path = require('path')
const CONFIG = require('./src/config/app.config')

const {
  port,
  publicPath,
  assetsDir,
  outputDir,
  productionSourceMap,
  lintOnSave,
  autoOpen,
  overlay
} = CONFIG

module.exports = {
  publicPath,
  outputDir,
  assetsDir,
  productionSourceMap,
  lintOnSave,
  devServer: {
    port,
    open: autoOpen,
    overlay,
    proxy: {}
  },
  // css: {
  //   requireModuleExtension: true // 开启CSSmodule并保留xxx.module.css后缀
  // },
  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'scss',
      patterns: [
        path.resolve(__dirname, 'src/styles/_variables.scss'),
        path.resolve(__dirname, 'src/styles/_mixins.scss')
      ]
    }
  },
  configureWebpack() {
    return {
      resolve: {
        alias: {
          '@': resolve('src'),
          '*': resolve(''),
          assets: resolve('src/assets')
        }
      },
      module: {
        rules: [
          {
            test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files
            loader: '@intlify/vue-i18n-loader',
            include: [
              // Use `Rule.include` to specify the files of locale messages to be pre-compiled
              path.resolve(__dirname, 'src/lang')
            ]
          }
        ]
      },
      plugins: []
    }
  }
}
